package com.niiwoo.civet.user.service.duboo;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.niiwoo.activity.stage.dto.request.notice.NoviceTaskRecordRequestDTO;
import com.niiwoo.activity.stage.enums.activity.NoviceTaskPrizeEnum;
import com.niiwoo.civet.trade.constant.RabbitConstant;
import com.niiwoo.civet.trade.dto.common.InvestEvaluationDTO;
import com.niiwoo.civet.trade.service.invest.InvestDubboService;
import com.niiwoo.civet.trade.service.project.NovicePorjectDubboService;
import com.niiwoo.civet.user.dao.entity.*;
import com.niiwoo.civet.user.dto.UserPersonalDubboInfoDTO;
import com.niiwoo.civet.user.dto.request.*;
import com.niiwoo.civet.user.dto.response.*;
import com.niiwoo.civet.user.enums.*;
import com.niiwoo.civet.user.service.ActivityDubboService;
import com.niiwoo.civet.user.service.ImDubboService;
import com.niiwoo.civet.user.service.UserBasicInfoDubboService;
import com.niiwoo.civet.user.service.local.*;
import com.niiwoo.tripod.base.component.PrivacyMasks;
import com.niiwoo.tripod.provider.dto.response.PageResponseDTO;
import com.niiwoo.tripod.provider.exception.BizException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

import java.util.*;

/**
 * Created by huangmin on 2017/11/9.
 */
@Service(version = "1.0.0")
public class UserBasicInfoDubboServiceImpl implements UserBasicInfoDubboService {

    private static Logger log = LoggerFactory.getLogger(UserBasicInfoDubboServiceImpl.class);
    //昵称长度不能小于1个字节
    private static final double NICK_NAME_MINIMUM_LENGTH = 0.5;
    //昵称长度不能大于8个汉字
    private static final double NICK_NAME_MAXIMUM_LENGTH = 8;
    //个性签名长度不能大于80个字节(40个字)
    private static final double PERSONAL_SIGN_MAXIMUM_LENGTH = 40;
    //昵称修改期限
    private static final int NICK_NAME_MODIFY_TIME = 180;
    //意见反馈输入长度限制
    private static final double FEED_BACK_SAVE_MAXIMUM_LENGTH = 200;

    @Reference(version = "1.0.0")
    private InvestDubboService investDubboService;
    @Reference(version = "1.0.0")
    private ImDubboService imDubboService;
    @Reference(version = "1.0.0")
    private ActivityDubboService activityDubboService;

    @Autowired
    private UserStatusService userStatusService;
    @Autowired
    private UserBasicInfoService userBasicInfoService;
    @Autowired
    private UserDataService userDataService;
    @Autowired
    private PrivacyMasks privacyMasks;
    @Autowired
    private UserAreaDictionaryService userAreaDictionaryService;
    @Autowired
    private UserIdentityService userIdentityService;
    @Autowired
    private UserLoginAccountService userLoginAccountLocalService;

    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Reference(version = "1.0.0")
    private NovicePorjectDubboService novicePorjectDubboService;

    @Override
    public UserBasicInfoResponseDTO getUserBasicInfo(String userId) {
        UserBasicInfoResponseDTO responseDTO = userBasicInfoService.getUserBaseInfo(userId);
        Optional.ofNullable(userIdentityService.getByUserId(userId))
                .map(IdentityInfo::getIdCard)
                .filter(StringUtils::isNotBlank)
                .ifPresent(idCardText -> {
                    String idCard = privacyMasks.decryptPrivacy(idCardText);
                    String provinceCode = idCard.substring(0, 2).concat("0000");
                    String cityCode = idCard.substring(0, 4).concat("00");
                    responseDTO.setProvinceName(Optional.ofNullable(userAreaDictionaryService.get(provinceCode)).map(UserAreaDictionary::getAreaName).orElse(""));
                    responseDTO.setCityName(Optional.ofNullable(userAreaDictionaryService.get(cityCode)).map(UserAreaDictionary::getAreaName).orElse(""));
                });
        return responseDTO;
    }

    @Override
    public UserBasicInfoResponseDTO selectUserBaseInfo(String userId) {

        return userBasicInfoService.selectUserBaseInfo(userId);
    }

    /**
     * 获取用户基本信息
     *
     * @param userId
     * @return
     */
    @Override
    public UserBasicInfoResponseDTO getUserBasicInfoForAsset(String userId) {
        Assert.notNull(userId, "资产端查询用户基本信息,用户Id为空!");
        UserBasicInfoResponseDTO responseDTO = new UserBasicInfoResponseDTO();
        return userBasicInfoService.queryUserBasicInfoForAsset(userId);
    }

    @Override
    public void showWindowCallback(String userId) {
        UserBasicInfo userBasicInfo = new UserBasicInfo();
        userBasicInfo.setUserId(userId);
        userBasicInfo.setWindowFlag(UserBasicEnum.UserWindowFlag.NOTIFIED.getType());
        if (!userBasicInfoService.updateInfo(userBasicInfo)) {
            throw new BizException("USR10013");
        }
    }

    @Override
    public void updateUserNickName(UserBasicInfoRequestDTO userBasicInfoRequestDTO, String nickName) {
        UserBasicInfo userBasicInfo = userBasicInfoService.selectUserBasicInfo(userBasicInfoRequestDTO.getUserId());
        if (UserBasicEnum.UserNickNameFlag.INFORMATION_PAGE.getType().equals(userBasicInfoRequestDTO.getUpdateType())) {
            if (userBasicInfo.getNickNameModifyTime() != null) {
                DateTime nickNameModifyTime = new DateTime(userBasicInfo.getNickNameModifyTime());
                DateTime canModifyTime = nickNameModifyTime.plusDays(NICK_NAME_MODIFY_TIME);
                if (canModifyTime.isAfterNow()) {
                    String modifyTime = FastDateFormat.getInstance("yyyy-MM-dd").format(canModifyTime.toDate());
                    throw new BizException("USR10011", modifyTime);
                }
            }
        }
        //判断昵称是否包含敏感词
        JSONObject jsonObject = userBasicInfoService.checkSensitiveWords(userBasicInfoRequestDTO.getNickName());
        if (jsonObject != null && (jsonObject.get("match_words") != null && jsonObject.get("sentence_replace") != null)) {
            JSONArray jsonArray = JSONArray.parseArray(jsonObject.get("match_words").toString());
            log.error("包含敏感词###jsonArray={}", jsonArray);
            String matchWords = "";
            for (Object word : jsonArray) {
                matchWords += matchWords.equals("") ? "" + word : "," + word;
            }
            throw new BizException("USR10029", matchWords);
        }
        //判断昵称是否存在
        Integer nickNameCount = userBasicInfoService.selectUserNickNameLibrary(nickName);
        if (nickNameCount != null && nickNameCount > 0) {
            throw new BizException("USR10008");
        }
        //判断昵称长度
        if (NICK_NAME_MINIMUM_LENGTH > userBasicInfoService.getLength(userBasicInfoRequestDTO.getNickName())
                || userBasicInfoService.getLength(userBasicInfoRequestDTO.getNickName()) > NICK_NAME_MAXIMUM_LENGTH) {
            throw new BizException("USR10009");
        }
        userBasicInfoService.updateUserNickName(userBasicInfoRequestDTO, userBasicInfo.getNickName());
        //推送修改昵称到IM
        UpdateUserBasicInfIMRequestDTO requestDTO = new UpdateUserBasicInfIMRequestDTO();
        requestDTO.setGuid(userBasicInfoRequestDTO.getUserId());
        requestDTO.setNickname(userBasicInfoRequestDTO.getNickName());
        try {
            log.info("用户昵称变更###调用IM###请求成功,userId={}, request={}", userBasicInfoRequestDTO.getUserId(), JSON.toJSONString(requestDTO));
            imDubboService.updateUserBasicInfIM(requestDTO);
        } catch (Exception e) {
            log.error("用户昵称变更###调用IM###请求失败,userId={}, errorMessage={}", userBasicInfoRequestDTO.getUserId(), e.getMessage());
        }
        try {
            //修改昵称成功，发送MQ消息  -->用户是否新手任务
            NoviceTaskRecordRequestDTO dto = new NoviceTaskRecordRequestDTO();
            dto.setUserId(userBasicInfoRequestDTO.getUserId());
            dto.setTaskType(NoviceTaskPrizeEnum.FRIST_NICENAME.getCode());
            rabbitTemplate.convertAndSend(RabbitConstant.Exchange.NOVICE_TASK_RECORD, RabbitConstant.RoutingKey.NOVICE_TASK_RECORD, dto);
        } catch (Exception e) {
            log.error("novice_task_activity用户昵称变更###调用否新手任务###请求失败,userId={}, errorMessage={}", userBasicInfoRequestDTO.getUserId(), e.getMessage());
        }
    }

    @Override
    public Date updateUserNickNameState(String userId) {
        UserBasicInfo basicInfo = userBasicInfoService.selectUserBasicInfo(userId);
        return basicInfo.getNickNameModifyTime();
    }

    @Override
    public void updateUserPersonalSign(UserBasicInfoRequestDTO userBasicInfoRequestDTO) {
        JSONObject jsonObject = userBasicInfoService.checkSensitiveWords(userBasicInfoRequestDTO.getPersonalSign());
        //判断昵称是否包含敏感词
        if (jsonObject != null && (jsonObject.get("match_words") != null && jsonObject.get("sentence_replace") != null)) {
            userBasicInfoRequestDTO.setPersonalSign(jsonObject.get("sentence_replace").toString());
        }
        //判断个性签名长度
        if (PERSONAL_SIGN_MAXIMUM_LENGTH < userBasicInfoService.getLength(userBasicInfoRequestDTO.getPersonalSign())) {
            throw new BizException("USR10010");
        }
        userBasicInfoService.updateUserPersonalSign(userBasicInfoRequestDTO);
        //推送修改个性签名到IM
        UpdateUserBasicInfIMRequestDTO requestDTO = new UpdateUserBasicInfIMRequestDTO();
        requestDTO.setGuid(userBasicInfoRequestDTO.getUserId());
        requestDTO.setIntroduction(userBasicInfoRequestDTO.getPersonalSign());
        try {
            log.info("用户个性签名变更###调用IM###请求成功,userId={}, request={}", userBasicInfoRequestDTO.getUserId(), JSON.toJSONString(requestDTO));
            imDubboService.updateUserBasicInfIM(requestDTO);
        } catch (Exception e) {
            log.error("用户个性签名变更###调用IM###请求失败,userId={}, errorMessage={}", userBasicInfoRequestDTO.getUserId(), e.getMessage());
        }
    }


    @Override
    public void updateHeadImage(UserBasicInfoRequestDTO userBasicInfoDTO) {
        userBasicInfoService.updateHeadImage(userBasicInfoDTO);
        //推送修头像称到IM
        UpdateUserBasicInfIMRequestDTO requestDTO = new UpdateUserBasicInfIMRequestDTO();
        requestDTO.setGuid(userBasicInfoDTO.getUserId());
        requestDTO.setAvatar(userBasicInfoDTO.getHeadImage());
        try {
            log.info("用户头像变更###调用IM###请求成功,userId={}, request={}", userBasicInfoDTO.getUserId(), JSON.toJSONString(requestDTO));
            imDubboService.updateUserBasicInfIM(requestDTO);
        } catch (Exception e) {
            log.error("用户头像变更###调用IM###请求失败,userId={}, errorMessage={}", userBasicInfoDTO.getUserId(), e.getMessage());
        }
        //修改头成功，发送MQ消息  -->用户是否新手任务
        try {
            NoviceTaskRecordRequestDTO dto = new NoviceTaskRecordRequestDTO();
            dto.setUserId(userBasicInfoDTO.getUserId());
            dto.setTaskType(NoviceTaskPrizeEnum.FRIST_IMAGE.getCode());
            rabbitTemplate.convertAndSend(RabbitConstant.Exchange.NOVICE_TASK_RECORD, RabbitConstant.RoutingKey.NOVICE_TASK_RECORD, dto);
        } catch (Exception e) {
            log.error("novice_task_activity用户头像变更###调用否新手任务###请求失败,userId={}, errorMessage={}", userBasicInfoDTO.getUserId(), e.getMessage());
        }

    }

    @Override
    public NiiwooScoreResponseDTO selectUserNiiwooScore(String userId) {

        return userBasicInfoService.selectUserNiiwooScore(userId);
    }

    @Override
    public PageResponseDTO selectNiwoScoreRecordListByPage(NiiwooScorePageRequestDTO niiwooScorePageRequestDTO) {

        return userBasicInfoService.selectNiwoScoreRecordListByPage(niiwooScorePageRequestDTO);
    }


    @Override
    public int insertBatchNiwoScore(JSONArray scoreArray) {

        return userBasicInfoService.insertBatchNiwoScore(scoreArray);
    }

    @Override
    public MyPageUserInfoDTO getMyPageUserInfo(String uerId) {
        UserBasicInfoResponseDTO userBasicInfoResponse = userBasicInfoService.getUserBaseInfo(uerId);
        if (userBasicInfoResponse == null) {
            throw new BizException("USR10006");
        }
        MyPageUserInfoDTO myPageUserInfoDTO = new MyPageUserInfoDTO();
        myPageUserInfoDTO.setNickName(userBasicInfoResponse.getNickName());
        myPageUserInfoDTO.setHeadImage(userBasicInfoResponse.getHeadImage());
        myPageUserInfoDTO.setNiiwooCode(userBasicInfoResponse.getNiiwooCode());
        myPageUserInfoDTO.setNiiwooScore(userBasicInfoResponse.getNiiwooScore());
        myPageUserInfoDTO.setNiiwooScoreTip(userBasicInfoResponse.getNiiwooFlag());
        myPageUserInfoDTO.setUserSeletctInvestLoanTag(userBasicInfoResponse.getUserSeletctInvestLoanTag());
        // 个人风险评测等级
        InvestEvaluationDTO investEvaluation = investDubboService.getInvestEvaluationInfo(uerId);
        byte hadEvaluate = investEvaluation.getHadEvaluate().byteValue();
        myPageUserInfoDTO.setEvaluationLevel(hadEvaluate == 0 ? 0 : investEvaluation.getLevel());
        return myPageUserInfoDTO;
    }

    @Override
    public List<UserBasicInfoDTO> queryListByUserIdSet(Set<String> userIdSet) {
        List<UserBasicInfo> list = userBasicInfoService.queryListByUserIdSet(userIdSet);
        List<UserBasicInfoDTO> resultList = new ArrayList<>();
        for (UserBasicInfo u : list) {
            UserBasicInfoDTO dto = new UserBasicInfoDTO();
            dto.setUserId(u.getUserId());
            dto.setMobileNo(u.getMobileNo());
            dto.setRegisterChannel(u.getRegisterChannel());
            dto.setIdentityTag(u.getIdentityTag());
            dto.setNiiwooCode(u.getNiiwooCode());
            dto.setNiiwooScore(u.getNiiwooScore());
            dto.setNickName(u.getNickName());
            dto.setNickNameModifyTime(u.getNickNameModifyTime());
            dto.setHeadImage(u.getHeadImage());
            dto.setGender(u.getGender());
            dto.setPersonalSign(u.getPersonalSign());
            dto.setCreateTime(u.getCreateTime());
            dto.setUpdateTime(u.getUpdateTime());
            resultList.add(dto);
        }
        return resultList;
    }

    @Override
    public QueryBasicInfoResponseDTO queryUserBasicInfo(QueryUserBasicInfoRequestDTO requestDTO) {
        log.info("queryUserBasicInfo###QueryUserBasicInfoRequestDTO={}", JSON.toJSON(requestDTO));
        if (requestDTO.getType() == null) {
            throw new BizException("USR10014");
        }
        if (StringUtils.isBlank(requestDTO.getMobileNo()) && StringUtils.isBlank(requestDTO.getUserId())) {
            throw new BizException("USR10030");
        }
        if(QueryBasicInfoEnum.MOBILE_NO.equals(requestDTO.getType())){
            LoginAccountMapping loginAccountMapping = userLoginAccountLocalService.getAccountMapping(privacyMasks.encryptPrivacy(requestDTO.getMobileNo()));
            log.info("queryUserBasicInfo###loginAccountMapping={}", JSON.toJSON(loginAccountMapping));
            if(loginAccountMapping == null)
                return null;
            requestDTO.setUserId(loginAccountMapping.getUserId());
        }
        QueryBasicInfoResponseDTO responseDTO =  userBasicInfoService.selectAuthenticationInfoByUserId(requestDTO.getUserId());
        if (responseDTO == null) {
            log.info("QueryBasicInfoResponseDTO查询为null");
            return null;
        }
        responseDTO.setMobileNo(responseDTO.getMobileNo() != null ? privacyMasks.decryptPrivacy(responseDTO.getMobileNo()) : "");
        responseDTO.setIdcard(responseDTO.getIdcard() != null ? privacyMasks.decryptPrivacy(responseDTO.getIdcard()) : "");
        DataStatus dataStatus = userStatusService.getByUserIdAndType(requestDTO.getUserId(), UserDataTypeEnum.TWO_ELEMENT);
        responseDTO.setIsAuthentication(dataStatus == null ? UserDataStatusEnum.RealNameAuthStatus.NOT_CERTIFIED.getStatus()
                : UserDataStatusEnum.RealNameAuthStatus.PASS_CERTIFIED.getStatus());
        log.info("queryUserBasicInfo###QueryBasicInfoResponseDTO={}", JSON.toJSON(responseDTO));
        return responseDTO;
    }

    @Override
    public void changeUserIdentityTag(String userId, UserIdentityEnum identityEnum) {
        UpdateUserBasicInfIMRequestDTO requestDTO = new UpdateUserBasicInfIMRequestDTO();
        requestDTO.setGuid(userId);
        UserBasicInfo userBasicInfo = userBasicInfoService.selectUserBasicInfo(userId);
        if (identityEnum == null || userBasicInfo == null) {
            return;
        }
        log.info("用户身份变更###调用IM###请求,userId={}, identityEnum={}", userId, identityEnum.getDesc());
        String identityTagStr = userBasicInfo.getIdentityTag();
        // 既是借款人又是投资人不做处理
        if (UserEnum.IdentityTag.INVEST_BORROWER.getType().equals(identityTagStr)) {
            return;
        }
        UserBasicInfo newUserBasicInfo = new UserBasicInfo();
        newUserBasicInfo.setUserId(userId);
        switch (identityEnum) {
            case INVESTOR:
                if (UserEnum.IdentityTag.BORROWER.getType().equals(identityTagStr)) {
                    requestDTO.setAddIdentity(IMIdentityTypeEnum.IS_BORROWER.getValue());
                    newUserBasicInfo.setIdentityTag(UserEnum.IdentityTag.INVEST_BORROWER.getType());
                    userBasicInfoService.updateInfo(newUserBasicInfo);
                } else if (UserEnum.IdentityTag.NO_IDENTITY.getType().equals(identityTagStr)) {
                    requestDTO.setAddIdentity(IMIdentityTypeEnum.INVESTOR.getValue());
                    newUserBasicInfo.setIdentityTag(UserEnum.IdentityTag.INVESTOR.getType());
                    userBasicInfoService.updateInfo(newUserBasicInfo);
                }
                break;
            case BORROWER:
                if (UserEnum.IdentityTag.INVESTOR.getType().equals(identityTagStr)) {
                    newUserBasicInfo.setIdentityTag(UserEnum.IdentityTag.INVEST_BORROWER.getType());
                    requestDTO.setAddIdentity(IMIdentityTypeEnum.INVESTOR.getValue());
                    userBasicInfoService.updateInfo(newUserBasicInfo);
                } else if (UserEnum.IdentityTag.NO_IDENTITY.getType().equals(identityTagStr)) {
                    requestDTO.setAddIdentity(IMIdentityTypeEnum.IS_BORROWER.getValue());
                    newUserBasicInfo.setIdentityTag(UserEnum.IdentityTag.BORROWER.getType());
                    userBasicInfoService.updateInfo(newUserBasicInfo);
                }
                break;
            default:
                log.warn("changeUserIdentityTag：identityEnum不存在");
                return;
        }

        if(requestDTO.getAddIdentity() != null && !requestDTO.getAddIdentity().equals(0)){
            try {
                log.info("用户身份变更###调用IM###请求成功,userId={}, request={}", userId, JSON.toJSONString(requestDTO));
                imDubboService.updateUserBasicInfIM(requestDTO);

                // 同步给活动库
                activityDubboService.synToActivity(requestDTO);
            } catch (Exception e) {
                log.error("用户身份变更###调用IM###请求失败,userId={}, errorMessage={}", userId, e.getMessage());
            }
        }
    }

    /**
     * 根据身份证号查询用户id
     *
     * @param mobileNo 手机号码
     * @return
     */
    @Override
    public String queryUserIdByMobileNo(String mobileNo) {
        return userBasicInfoService.queryUserIdByMobileNo(privacyMasks.encryptPrivacy(mobileNo));
    }

    /**
     * 根据昵称查询用户id
     *
     * @param nickName
     * @return
     */
    @Override
    public String queryUserIdByNickName(String nickName) {
        return userBasicInfoService.queryUserIdByNickName(nickName);
    }


    @Override
    public boolean feedBackSave(FeedBackSaveRequestDTO requestDTO) {
        if(userBasicInfoService.getLength(requestDTO.getContent()) > FEED_BACK_SAVE_MAXIMUM_LENGTH){
            throw new BizException("USR10018");
        }
        return userBasicInfoService.feedBackSave(requestDTO);
    }



    @Override
    public UserContractInfoDTO getUserContractInfo(String userId) {
        UserBasicInfo userBasicInfo = userBasicInfoService.selectUserBasicInfo(userId);
        if (userBasicInfo == null) {
            return null;
        }
        UserContractInfoDTO userContractInfoDTO = new UserContractInfoDTO();
        userContractInfoDTO.setMobileNo(privacyMasks.decryptPrivacy(userBasicInfo.getMobileNo()));
        UserPersonalDubboInfoDTO userPersonalInfo = userDataService.userPersonalInfo(userId);
        if (userPersonalInfo != null) {
            StringBuilder sbAdrr = new StringBuilder();
            sbAdrr.append(userPersonalInfo.getLivingProvince());
            sbAdrr.append(userPersonalInfo.getLivingCity());
            sbAdrr.append(userPersonalInfo.getLivingArea());
            sbAdrr.append(userPersonalInfo.getLivingAddress());
            userContractInfoDTO.setLivingAdress(sbAdrr.toString());
            userContractInfoDTO.setEmail(userPersonalInfo.getEmail());
        }
        return userContractInfoDTO;
    }

    @Override
    public PlatformStatisticsResponseDTO platformStatisticsInformation() {

        return userBasicInfoService.platformStatisticsInformation();
    }

    @Override
    public QueryBasicInfoResponseDTO queryUserBasicInfoByIdCard(String idCard) {
        log.info("queryUserBasicInfoByIdCard###IdCard={}", idCard);
        if (StringUtils.isBlank(idCard) )
            throw new BizException("USR10031");

        QueryBasicInfoResponseDTO responseDTO = userIdentityService.queryUserAuthenticationInfo(privacyMasks.encryptPrivacy(idCard));
        if (responseDTO == null)
            return null;
        responseDTO.setMobileNo(responseDTO.getMobileNo() != null ? privacyMasks.decryptPrivacy(responseDTO.getMobileNo()) : "");
        responseDTO.setIdcard(responseDTO.getIdcard() != null ? privacyMasks.decryptPrivacy(responseDTO.getIdcard()) : "");
        DataStatus dataStatus = userStatusService.getByUserIdAndType(responseDTO.getUserId(), UserDataTypeEnum.TWO_ELEMENT);
        responseDTO.setIsAuthentication(dataStatus == null ? UserDataStatusEnum.RealNameAuthStatus.NOT_CERTIFIED.getStatus()
                : UserDataStatusEnum.RealNameAuthStatus.PASS_CERTIFIED.getStatus());
        log.info("queryUserBasicInfo###QueryBasicInfoResponseDTO={}", JSON.toJSON(responseDTO));
        return responseDTO;
    }

	@Override
	public GetInviteCodeResponseDTO getInviteCode(String userId) {
		GetInviteCodeResponseDTO responseDTO = new GetInviteCodeResponseDTO();
		responseDTO.setCode(userBasicInfoService.getInviteCode(userId));
		return responseDTO;
	}


}
